package com.haoshuang.zhouzhoubang.ui.page.welfare.insure.apply

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class InsureApplyViewModel : BaseViewModel() {

    /**
     * 保险申请
     */
    val applyMasterInsuranceData = StatefulMutableLiveData<Any>()
    fun applyMasterInsurance(json: String) = netRequest {
        start { applyMasterInsuranceData.value = StateData.Loading }
        request { ApiRepo.applyMasterInsurance(json)  }
        success { applyMasterInsuranceData.value = StateData.Success(it.data) }
        error { code, msg ->
            applyMasterInsuranceData.value = StateData.Error(code, msg)
        }
    }

}